<link href="__PUBLIC__/plugins/fitui/tablegrid.css" rel="stylesheet">
<script src="__PUBLIC__/plugins/fitui/tablegrid.js"></script>
<script src="__PUBLIC__/js/mp/generate_code.js"></script>
<script>
var Param = <?php echo json_encode( $param ) ?> ;
$(function(){
  GenerateCode.init(<?php echo json_encode( $config ) ?>);
});

</script>

<div class="page-content">
  <ol class="breadcrumb">
    <li><a href="<?php echo $home_url ?>">首页</a></li>
    <li class="active"><?php echo $module_name ?></li>
  </ol>
  <div class="page-content-inner">
    <div class="portlet blue" id="read_modal">
      <div class="portlet-title">
        <div class="caption"> <i class="fa fa-wrench  "></i> <?php echo $module_name ?> </div>
      </div>
      <div class="portlet-body">
        <form class="form-inline search-form" method="post">
          <div style="margin-bottom: 16px;">
            <div class="form-group">
              <label for="keywords">表名：</label>
              <input type="text" class="form-control" id="tablename" placeholder="输入表名">
            </div>
            <button type="button" class="btn btn-primary" id="search_btn"><i class="fa fa-search"> </i> 查询</button>
          </div>
          <div id="add_btn" style="display:none;">
            <button type="button" class="btn btn-primary" id="load_add_model_btn"><i class="fa fa-medium"> </i> 生成 Model</button>
            <button type="button" class="btn btn-primary" id="load_add_service_btn"><i class="fa fa-usd"> </i> 生成 Service</button>
            <button type="button" class="btn btn-primary" id="load_add_controller_btn"><i class="fa fa-eur"> </i> 生成 Controller</button>

            <div class="btn-group">
              <button type="button" class="btn btn-primary"><i class="fa fa-gbp "></i> 生成 JS</button>
              <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
                <span class="caret"></span>
                <span class="sr-only">Toggle Dropdown</span>
              </button>
              <ul class="dropdown-menu" role="menu">
                <li><a href="#" class="load_add_js_btn" data-type="div" >Div模式</a></li>
                <li><a href="#" class="load_add_js_btn" data-type="modal" >Modal模式</a></li>
              </ul>
            </div>
            
            <div class="btn-group">
              <button type="button" class="btn btn-primary"><i class="fa fa-jpy "></i> 生成 View</button>
              <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
                <span class="caret"></span>
                <span class="sr-only">Toggle Dropdown</span>
              </button>
              <ul class="dropdown-menu" role="menu">
                <li><a href="#" class="load_add_view_btn" data-type="div" >Div模式</a></li>
                <li><a href="#" class="load_add_view_btn" data-type="modal" >Modal模式</a></li>
              </ul>
            </div> 
            
          </div>
        </form> <!-- end search_form -->
      
        <div class="table-responsive" id="tablegrid">
          <table id="data_table" class="table table-striped table-hover table-condensed">
            <thead>
              <tr>
                <th width="160"  data-field="field_name" data-sortable="true">字段</th>
                <th width="100" data-field="field_type">类型</th>
                <th width="320" data-field="field_comment" >备注</th>
                <th width="160" data-field="field_default" data-formatter="format_default" >默认值</th>
                <th width="160" data-field="field_text" data-formatter="format_text" >名称</th>
                <th width="80" data-field="field_width" data-formatter="format_width" >宽度</th>
                <th width="80" data-field="field_sort" data-formatter="format_sort" >是否排序</th>
                <th width="160" data-field="field_format" data-formatter="format_format" >格式化函数</th>
                
                <th>&nbsp;</th>
              </tr>
            </thead>
          </table>
        </div><!-- end tablegrid -->
        
      </div><!-- end portlet-body -->
    </div><!-- end portlet -->
  </div><!-- end page-content-inner -->
</div><!-- end page-content -->

<!-- model 窗口 -->
<div class="modal fade" id="model_modal">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title">自动生成Model</h4>
      </div>
      <div class="modal-body">
        <form class="form-horizontal" id="model_form">
          <div class="form-group">
            <label for="filename" class="col-sm-3 control-label">文件路径</label>
            <div class="col-sm-8">
              <input type="text" class="form-control" name="filename" placeholder="文件路径">
            </div>
          </div>
          <div class="form-group">
            <label for="name" class="col-sm-3 control-label">类名</label>
            <div class="col-sm-8">
              <input type="text" class="form-control" name="classname" placeholder="类名">
            </div>
          </div>
          <div class="form-group">
            <label for="name" class="col-sm-3 control-label">实例名</label>
            <div class="col-sm-8">
              <input type="text" class="form-control" name="name" placeholder="实例名">
            </div>
          </div>
          <div class="form-group">
            <label for="tablename" class="col-sm-3 control-label">表名</label>
            <div class="col-sm-8">
              <input type="text" class="form-control" name="tablename" placeholder="表名">
            </div>
          </div>

        </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal"><i class="fa fa-times"></i> 关闭</button>
        <button type="button" class="btn btn-primary" id="add_model_btn"><i class="fa fa-check"></i> 生成</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<!-- service 窗口 -->
<div class="modal fade" id="service_modal">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title">自动生成Service</h4>
      </div>
      <div class="modal-body">
        <form class="form-horizontal" id="service_form">
          <div class="form-group">
            <label for="filename" class="col-sm-3 control-label">文件路径</label>
            <div class="col-sm-8">
              <input type="text" class="form-control" name="filename" placeholder="文件路径">
            </div>
          </div>
          <div class="form-group">
            <label for="name" class="col-sm-3 control-label">类名</label>
            <div class="col-sm-8">
              <input type="text" class="form-control" name="classname" placeholder="类名">
            </div>
          </div>
          <div class="form-group">
            <label for="name" class="col-sm-3 control-label">实例名</label>
            <div class="col-sm-8">
              <input type="text" class="form-control" name="name" placeholder="实例名">
            </div>
          </div>
          <div class="form-group">
            <label for="tablename" class="col-sm-3 control-label">Model名</label>
            <div class="col-sm-8">
              <input type="text" class="form-control" name="modelname" placeholder="表名">
            </div>
          </div>

        </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal"><i class="fa fa-times"></i> 关闭</button>
        <button type="button" class="btn btn-primary" id="add_service_btn"><i class="fa fa-check"></i> 生成</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<!-- controller 窗口 -->
<div class="modal fade" id="controller_modal">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title">自动生成Service</h4>
      </div>
      <div class="modal-body">
        <form class="form-horizontal" id="controller_form">
          <div class="form-group">
            <label for="filename" class="col-sm-3 control-label">文件路径</label>
            <div class="col-sm-8">
              <input type="text" class="form-control" name="filename" placeholder="文件路径">
            </div>
          </div>
          <div class="form-group">
            <label for="name" class="col-sm-3 control-label">类名</label>
            <div class="col-sm-8">
              <input type="text" class="form-control" name="classname" placeholder="类名">
            </div>
          </div>
          <div class="form-group">
            <label for="name" class="col-sm-3 control-label">方法名</label>
            <div class="col-sm-8">
              <input type="text" class="form-control" name="name" placeholder="方法名">
            </div>
          </div>
          <div class="form-group">
            <label for="name" class="col-sm-3 control-label">Service名</label>
            <div class="col-sm-8">
              <input type="text" class="form-control" name="service" placeholder="Service名">
            </div>
          </div>
          <div class="form-group">
            <label for="tablename" class="col-sm-3 control-label">Service类名</label>
            <div class="col-sm-8">
              <input type="text" class="form-control" name="service_classname" placeholder="Service类名">
            </div>
          </div>
          <div class="form-group">
            <label for="tablename" class="col-sm-3 control-label">模块名</label>
            <div class="col-sm-8">
              <input type="text" class="form-control" name="module" placeholder="模块名">
            </div>
          </div>
          <div class="form-group">
            <label for="tablename" class="col-sm-3 control-label">模块类名</label>
            <div class="col-sm-8">
              <input type="text" class="form-control" name="module_classname" placeholder="模块名">
            </div>
          </div>
        </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal"><i class="fa fa-times"></i> 关闭</button>
        <button type="button" class="btn btn-primary" id="add_controller_btn"><i class="fa fa-check"></i> 生成</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<!-- js 窗口 -->
<div class="modal fade" id="js_modal">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title">自动生成 JS</h4>
      </div>
      <div class="modal-body">
        <form class="form-horizontal" id="js_form">
          <div class="form-group">
            <label for="name" class="col-sm-3 control-label">类型</label>
            <div class="col-sm-8">
              <input type="text" class="form-control" name="type" placeholder="类名">
            </div>
          </div>
          <div class="form-group">
            <label for="filename" class="col-sm-3 control-label">文件路径</label>
            <div class="col-sm-8">
              <input type="text" class="form-control" name="filename" placeholder="文件路径">
            </div>
          </div>
          <div class="form-group">
            <label for="name" class="col-sm-3 control-label">类名</label>
            <div class="col-sm-8">
              <input type="text" class="form-control" name="classname" placeholder="类名">
            </div>
          </div>

        </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal"><i class="fa fa-times"></i> 关闭</button>
        <button type="button" class="btn btn-primary" id="add_js_btn"><i class="fa fa-check"></i> 生成</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<!-- view 窗口 -->
<div class="modal fade" id="view_modal">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title">自动生成 View</h4>
      </div>
      <div class="modal-body">
        <form class="form-horizontal" id="view_form">
          <div class="form-group">
            <label for="name" class="col-sm-3 control-label">类型</label>
            <div class="col-sm-8">
              <input type="text" class="form-control" name="type" placeholder="类名">
            </div>
          </div>
          <div class="form-group">
            <label for="filename" class="col-sm-3 control-label">文件路径</label>
            <div class="col-sm-8">
              <input type="text" class="form-control" name="filename" placeholder="文件路径">
            </div>
          </div>
          <div class="form-group">
            <label for="name" class="col-sm-3 control-label">模块名</label>
            <div class="col-sm-8">
              <input type="text" class="form-control" name="low_module" placeholder="模块名">
            </div>
          </div>
          <div class="form-group">
            <label for="name" class="col-sm-3 control-label">js文件名</label>
            <div class="col-sm-8">
              <input type="text" class="form-control" name="js_filename" placeholder="js文件名">
            </div>
          </div>
          <div class="form-group">
            <label for="name" class="col-sm-3 control-label">js类名</label>
            <div class="col-sm-8">
              <input type="text" class="form-control" name="js_classname" placeholder="js类名">
            </div>
          </div>
        </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal"><i class="fa fa-times"></i> 关闭</button>
        <button type="button" class="btn btn-primary" id="add_view_btn"><i class="fa fa-check"></i> 生成</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->